package algorithm;

/**
 * @description: 数组反转
 * 逻辑图：https://www.processon.com/view/link/6193d480079129330ae00396
 * @author: apple
 * @date:  2021/11/16 11:38 下午
 * @version 1.0
 **/
public class Reverse {

    public static void main(String[] args) {

        String[] ts = {"A" , "B" , "C" , "D"};

        System.out.println("交换前");

        for (int i = 0; i < ts.length; i++) {
            System.out.print(ts[i] + " ");
        }

        System.out.println();

       String temp = ts[ts.length - 1];
       ts[ts.length - 1] = ts[0];
       ts[0] = temp;

        System.out.println("第一轮交换");
        for (int i = 0; i < ts.length; i++) {
            System.out.print(ts[i] + " ");
        }
        System.out.println();

        temp = ts[ts.length - 2];
        ts[ts.length - 2] = ts[1];
        ts[1] = temp;


        System.out.println("第一轮交换");
        for (int i = 0; i < ts.length; i++) {
            System.out.print(ts[i] + " ");
        }
    }
}
